<%= render :partial =>'/store/toolbar'%>
<div id="content_container">
  <hr  class="break"/>
  <h2>加盟商须知</h2>

  <p>
    <label>给消费者折扣:</label>
    <%= foramt_percentage @user.discount ? @user.discount : 0  %>
  </p>

  <p>
    <label>代理商回佣金:</label>
    <%= foramt_percentage COMMISSION  %>
  </p>

  <p>
    <label>宣传优惠码:</label>
    <%=@user.code%>
  </p>

  <hr  class="break"/>
  <h2>收益记录</h2>
  <p>
    <label>广告点击量:</label><%= @user.click_count%>
  </p>
  <p>
    <label>通过点击你的广告进入网站,并完成交易的订单:</label>
  </p>

  <table class="admin"  cellpadding="0" cellspacing="0" >
    <thead>
      <tr>
        <th>编号</th>
        <th>下单时间</th>
        <th>总金额(除运费)</th>
        <th>下单人</th>
        <th>状态</th>
        <th>预期收益</th>
      </tr>
    </thead>
    <tfoot>
      <tr>
        <td colspan="6">
          收益:
        </td>
      </tr>
    </tfoot>

    <tbody>
      <% for order in @orders %>
        <tr>
          <td><%= order.id%></td>
          <td><%= order.created_at.strftime("%y-%m-%d %I:%M%p") %></td>
          <td><%= number_to_currency(order.total_product_price,:unit => "&yen;")%></td>
          <td><%= order.user.login %></td>
          <td><%= format_status(order.status) %></td>
          <td><%= number_to_currency(order.total_product_price * COMMISSION,:unit => "&yen;")%></td>
        </tr>
      <% end %>
    </tbody>

  </table>

  <hr  class="break"/>
  <h2>提现</h2>
  <div>
    <% form_tag "/users/update_agent_status_withdraw/#{session[:user_id]}" do %>
      <p>
        <label>您现有的佣金:</label>
        <%= @user.account ? @user.account : 0  %>
        <% if @user.account && @user.account > 0 %>
          <input type="hidden" name="user[agent_status]" value="3" >
          <input type="submit" value="申请提现" />
        <%  end %>
      </p>
    <%  end %>
  </div>

  <div>
    <% if @user.withdraws.length > 0 %>
      <p>您的提现纪录</p>
      <table class="admin"  cellpadding="0" cellspacing="0" >
        <thead>
          <tr>
            <th>金额</th>
            <th>流水号</th>
            <th>汇款时间</th>
          </tr>
        </thead>
        <% for wd in @user.withdraws %>
          <tr>
            <td><%= wd.amount%></td>
            <td><%= wd.receipt %></td>
            <td><%= wd.created_at %></td>
          </tr>
        <% end %>
      </table>
    <%end%>
  </div>
</div>




